<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生列表 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            padding-top: 20px;
        }
        .navbar {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .navbar-brand, .navbar-nav > li > a {
            color: white !important;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <a class="navbar-brand" th:href="@{/teacher}">
                    <i class="fa fa-arrow-left"></i> 返回主页
                </a>
            </div>
            <ul class="nav navbar-nav">
                <li><a th:href="@{/teacher/student/list}">学生列表</a></li>
                <li><a th:href="@{/teacher/student/add}">添加学生</a></li>
            </ul>
        </div>
    </nav>
    
    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-list"></i> 学生列表</h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <!-- 搜索框 -->
                <div style="margin-bottom: 20px;">
                    <form th:action="@{/teacher/student/list}" method="get" class="form-inline">
                        <div class="form-group">
                            <label>按班级筛选：</label>
                            <input type="text" class="form-control" name="className" 
                                   th:value="${className}" placeholder="请输入班级名称（支持模糊查询）" 
                                   style="width: 200px;">
                        </div>
                        <div class="form-group" style="margin-left: 15px;">
                            <label>按学号筛选：</label>
                            <input type="text" class="form-control" name="studentNumber" 
                                   th:value="${studentNumber}" placeholder="请输入学号（支持模糊查询）" 
                                   style="width: 200px;">
                        </div>
                        <button type="submit" class="btn btn-primary" style="margin-left: 15px;">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a th:href="@{/teacher/student/list}" class="btn btn-default" style="margin-left: 10px;">
                            <i class="fa fa-refresh"></i> 重置
                        </a>
                        <a th:href="@{/teacher/student/add}" class="btn btn-success" style="margin-left: 10px;">
                            <i class="fa fa-plus"></i> 添加学生
                        </a>
                    </form>
                </div>
                
                <!-- 学生表格 -->
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>学号</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>专业</th>
                            <th>学院</th>
                            <th>班级</th>
                            <th>手机号</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr th:if="${#lists.isEmpty(students)}">
                            <td colspan="8" class="text-center">暂无学生数据</td>
                        </tr>
                        <tr th:each="student : ${students}">
                            <td th:text="${student.studentNumber}"></td>
                            <td th:text="${student.name}"></td>
                            <td th:text="${student.gender}"></td>
                            <td th:text="${student.major}"></td>
                            <td th:text="${student.college}"></td>
                            <td th:text="${student.className}"></td>
                            <td th:text="${student.phone}"></td>
                            <td>
                                <a th:href="@{/teacher/student/edit(id=${student.id})}" 
                                   class="btn btn-sm btn-warning">
                                    <i class="fa fa-edit"></i> 编辑
                                </a>
                                <a th:href="@{/teacher/student/delete(id=${student.id})}" 
                                   class="btn btn-sm btn-danger"
                                   onclick="return confirm('确定要删除该学生吗？')">
                                    <i class="fa fa-trash"></i> 删除
                                </a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>
</html>

